<template>
  <div class="app-container">
    <el-card class="pay-configuration">
      <el-form
        ref="elForm"
        class="pay-configuration-form"
        :model="formData"
        :rules="rules"
        size="medium"
        label-width="100px"
      >
        <el-row>
          <el-col :span="10">
            <title-line title="商户信息" />
            <el-form-item label="商户号：" prop="field101">
              <el-input v-model="formData.field101" placeholder="请输入微信商户号" clearable />
            </el-form-item>
            <el-form-item label="API秘钥：" prop="field102">
              <el-input v-model="formData.field102" placeholder="请输入小程序APPID" clearable />
            </el-form-item>
            <el-form-item label="商户证书：" prop="field103">
              <el-input v-model="formData.field103" placeholder="请选择商户证书" clearable />
            </el-form-item>
            <title-line title="启用状态" />
            <el-form-item label="" prop="field104" label-width="0">
              <el-radio-group v-model="formData.field104">
                <el-radio
                  v-for="(item, index) in field104Options"
                  :key="index"
                  :label="item.value"
                  :disabled="item.disabled"
                >
                  {{ item.label }}
                </el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item class="text-center">
              <el-button @click="resetForm"> 取消 </el-button>
              <el-button type="primary" @click="submitForm"> 保存 </el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
  </div>
</template>
<script>
export default {
  components: {},
  props: [],
  data() {
    return {
      formData: {
        field101: undefined,
        field102: undefined,
        field103: undefined,
        field104: 1
      },
      rules: {
        field101: [
          {
            required: true,
            message: '请输入微信商户号',
            trigger: 'blur'
          }
        ],
        field102: [
          {
            required: true,
            message: '请输入小程序APPID',
            trigger: 'blur'
          }
        ],
        field103: [
          {
            required: true,
            message: '请选择商户证书',
            trigger: 'blur'
          }
        ],
        field104: [
          {
            required: true,
            message: '不能为空',
            trigger: 'change'
          }
        ]
      },
      field104Options: [
        {
          label: '立即启用',
          value: 1
        },
        {
          label: '暂不启用',
          value: 2
        }
      ]
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    submitForm() {
      this.$refs['elForm'].validate(valid => {
        if (!valid) return
        // TODO 提交表单
      })
    },
    resetForm() {
      this.$refs['elForm'].resetFields()
      this.$router.back()
    }
  }
}
</script>
